Previous Book Contents Book Index Next

Inside Macintosh: 3D Graphics Programming With QuickDraw 3D /
Chapter 17 - File Objects / File Objects Reference
Application-Defined Routines /


TQ3ObjectReadDataMethod

You can define a method to read an object of your custom type and any attached subobjects from a file object.

typedef TQ3Status (*TQ3ObjectReadDataMethod) (
TQ3Object parentObject, 
TQ3FileObject file);
parentObject
An object to attach your custom data to.
file
A file object.
DESCRIPTION
Your TQ3ObjectReadDataMethod function should read an object and any attached subobjects from the current location in the file object specified by the file parameter and attach that object to the object specified by the parentObject parameter. If the object read is a custom element (or a custom attribute), you should allocate space on the stack and call Q3Set_Add (or Q3AttributeSet_Add) on the object specified by the parentObject parameter, which is a set (or an attribute set). If the object read is not an element, you should attach your custom data to the object specified by the parentObject parameter.

On entrance to your custom read method, you should read the custom object data using the primitive data type _Read functions described in "Reading and Writing File Data," beginning on page 17-27 (for example, Q3Uns64_Read and Q3Point3D_Read). In general, you know the structure of the custom object data, so you can stop reading when you've read an entire object. Alternatively, you can read data until the function Q3File_IsEndOfData returns kQ3True.

Once you've read the custom object data, you should read any subobjects attached to the object. Because a metafile object has subobjects only if it is in a container, you can use the Q3File_IsEndOfContainer function to determine whether there are any subobjects (if Q3File_IsEndOfContainer returns kQ3False, there are subobjects to read). If you have created an object, pass it to Q3File_IsEndOfContainer so that the subobjects with automatic attachment methods can be attached to your object. Otherwise, pass the value NULL to Q3File_IsEndOfContainer to have all subobjects returned to you. Note that when you call Q3File_IsEndOfContainer, all unread parent object data is skipped and a warning is issued.

At this point, you can use the functions that retrieve subobjects (for example, Q3File_GetNextObjectType and Q3File_ReadObject) to iterate through the subobjects until Q3File_IsEndOfContainer returns kQ3True.

RESULT CODES
Your TQ3ObjectReadDataMethod function should return kQ3Success if it is successful and kQ3Failure otherwise.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996